import request from '@/config/axios'

// 交易单元 VO
export interface TradingUnitVO {
  id: number // ID
  name: string // 交易名称
  tradingUnit: string // 交易单元
  state: string // 类型 0管理员 1企业
  mainId: string // 主表ID
}

// 交易单元 API
export const TradingUnitApi = {
  // 查询交易单元分页
  getTradingUnitPage: async (params: any) => {
    return await request.get({ url: `/dd/trading-unit/page`, params })
  },
  // 查询交易单元下拉框
  getTradingUnitSelect: async () => {
    return await request.get({ url: `/dd/trading-unit/list` })
  },
  // 获得我的交易单元
  getTradingUnitListMe: async (params: any) => {
    return await request.get({ url: `/dd/trading-unit/meList`,params })
  },
    // 查询交易单元下拉框Map
    getTradingUnitSelectMap: async () => {
      return await request.get({ url: `/dd/trading-unit/listMap` })
    },
     // 统计数据
     getCountDataData: async (params) => {
      return await request.get({ url: `/dd/trading-unit/getCountData`,params })
    },
  

  // 查询交易单元详情
  getTradingUnit: async (id: number) => {
    return await request.get({ url: `/dd/trading-unit/get?id=` + id })
  },

  // 新增交易单元
  createTradingUnit: async (data: TradingUnitVO) => {
    return await request.post({ url: `/dd/trading-unit/create`, data })
  },

  // 修改交易单元
  updateTradingUnit: async (data: TradingUnitVO) => {
    return await request.put({ url: `/dd/trading-unit/update`, data })
  },
  // 修改需求的交易单元
  updateDemandinfoUnitApi: async (data: TradingUnitVO) => {
    return await request.put({ url: `/dd/trading-unit/updateDemandinfoUnit`, data })
  },
  // 删除交易单元
  deleteTradingUnit: async (id: number) => {
    return await request.delete({ url: `/dd/trading-unit/delete?id=` + id })
  },

  // 导出交易单元 Excel
  exportTradingUnit: async (params) => {
    return await request.download({ url: `/dd/trading-unit/export-excel`, params })
  },
}
